@mixin borderRad8 {
  border-radius: 8px;
}
// 定义滚动动画
@keyframes scrollText {
  0% {
    transform: translateX(0);
  }
  100% {
    // 修复：使用负边距确保滚动完全
    transform: translateX(calc(-100% + 90px));
  }
}

@mixin voiceTypeTitle {
  color: #ffffffcc;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}
.soundBank {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  flex-wrap: wrap;
  padding: 16px;
  gap: 16px;

  .topToolColumn {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 48px;
  }

  .typeTab {
    width: 320px;
    display: flex;
    justify-content: center;
    height: 48px;

    .typeGroup {
      width: 324px;
      border-radius: 8px;
      height: 48px;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 24px;

      .typeItem {
        color: #fff;
        font-size: 14px;
        font-weight: 400;
        width: 110px;
        padding: 0;
        line-height: 34px;
      }
      :global(.semi-radio-addon-buttonRadio-checked) {
        background-color: #121317;
      }

      :global(.semi-radio-buttonRadioGroup-small) {
        padding: 0;
      }
      :global(.semi-radio-addon-buttonRadio-small) {
        border-radius: 8px !important;
      }
    }
  }

  .filterBox {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.8);

    .filterBtn {
      color: rgba(255, 255, 255, 0.8);
      font-weight: 400;
      padding: 4px 24px;
      border: 1px solid var(--border-color);

      &.filterBtnActive {
        border: 1px solid rgba(50, 109, 255, 1);
      }

      &.deleteBtn {
        display: flex;
        align-items: center;
        justify-content: center;

        .deleteIcon {
          margin-right: 6px;
        }
      }
      &.addBtn {
        @include borderRad8;
        margin-left: 18px;
      }
    }
  }

  .soundListBox {
    width: 100%;
    flex: 1;

    .soundCardItem {
      width: 140px;
      height: 168px;
      border-radius: 12px;
      border: 1px solid var(--border-color);
      padding: 24px;
      position: relative;
      // 添加卡片自身的过渡效果
      transition: border-color 0.3s ease;

      &.cardSelected {
        border: 1px solid rgba(49, 107, 255, 1);
        // 可以添加更多选中效果增强视觉反馈
        box-shadow: 0 0 0 2px rgba(49, 107, 255, 0.1);
      }

      :global(.semi-card-body) {
        padding: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
      }
      .soundAvatar {
        width: 88px;
        height: 88px;
      }

      // 文字容器样式
      .soundNameContainer {
        width: 90px; // 与Avatar宽度保持一致
        height: 22px;
        overflow: hidden;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        // 添加一些内边距，让文字在容器内有更好的呼吸空间
        padding: 0 2px;

        // 当文字溢出时应用动画
        &[data-overflow='true'] {
          .soundNameText {
            // 优化1：使用平滑的缓动函数替代linear
            // 优化2：调整动画持续时间，根据文字长度动态设置
            animation: scrollText 4s cubic-bezier(0.25, 0.1, 0.25, 1) infinite;
            // 优化3：设置animation-fill-mode确保动画起始状态正确
            animation-fill-mode: both;
          }
          &:hover .soundNameText {
            animation-play-state: paused; // 鼠标悬停在文字上时暂停动画
          }
        }
      }

      .soundNameText {
        color: #fff;
        font-size: 14px;
        font-weight: 400;
        line-height: 22px;
        white-space: nowrap;
        display: inline-block;
        will-change: transform;
        position: relative;
        // 优化4：设置animation-play-state默认值
        animation-play-state: running;

        // 优化：使用绝对定位避免伪元素影响原始宽度
        &::after {
          content: attr(data-text);
          position: absolute;
          left: 100%;
          top: 0;
          padding-left: 10px;
          // 确保伪元素不会被测量
          pointer-events: none;
          // 优化6：确保伪元素与主文本样式一致
          color: inherit;
          font-size: inherit;
          font-weight: inherit;
          line-height: inherit;
        }
      }

      .soundName {
        color: #fff;
        font-size: 14px;
        font-weight: 400;
        line-height: 22px;
      }
      &:hover {
        border: 1px solid rgba(49, 107, 255, 1);
        .moreIcon {
          opacity: 1;
          transform: scale(1) translateY(0);
        }
      }
      .moreIcon {
        opacity: 0;
        transform: scale(0.8) translateY(-5px);
        // 延长过渡时间并使用更平滑的曲线
        transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
          transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        position: absolute;
        top: 4px;
        right: 4px;
        cursor: var(--pointer);
        // 添加一个小的z-index确保在卡片内容之上
        z-index: 10;
      }
    }
  }
  .soundPlayer {
    width: 100%;
    height: 92px;

    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;

    .footerAudioName {
      color: #fff;
      font-size: 14px;
      font-weight: 500;
      line-height: 24px;
      width: 80px;
      flex-shrink: 0;
      // overflow: hidden;
      // text-overflow: ellipsis;
      // white-space: nowrap;
    }

    .footerAvatar {
      width: 60px;
      height: 60px;
      flex-shrink: 0;
    }
  }
}
.addModal {
  :global(.semi-modal-footer) {
    :global(.buttonPrimary:last-child) {
      width: 326px !important;
    }
  }

  .addModalContent {
    width: 100%;
    padding: 16px 24px 0px 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 16px;

    .addModalHeader {
      width: 100%;
      display: flex;
      justify-content: flex-start;
      align-items: center;
      gap: 16px;

      .avatarBox {
        width: 88px;
        height: 88px;
        position: relative;

        .avatarContent {
          width: 100%;
          height: 100%;
          left: 0;
          top: 0;
          z-index: 100;
          position: absolute;

          &:hover .mask {
            width: 100%;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
            z-index: 100;
            background-color: rgba(0, 0, 0, 0.5);
            border-radius: 50%;

            display: flex;
            justify-content: center;
            align-items: center;

            .avatarDeleteIcon {
              display: block;
            }
          }
          .avatarDeleteIcon {
            display: none;
            width: 24px;
            height: 24px;
            cursor: var(--pointer);
          }
        }
        .vocieAvatar {
          width: 100%;
          height: 100%;
        }
        .uploadBox {
          width: 100%;
          height: 100%;
          border-radius: 50%;

          display: flex;
          justify-content: center;
          align-items: center;

          :global(.arco-upload-trigger) {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background-color: #252525;
            cursor: var(--pointer);
            display: flex;
            justify-content: center;
            align-items: center;
          }

          .uploadIcon {
            width: 48px;
            height: 48px;
          }
        }
      }
      .addConfig {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        gap: 8px;

        .addvocieTitle {
          @include voiceTypeTitle;
        }
        .voiceNameInput {
          width: 100%;
          border: 1px solid var(--border-color);
        }
        .voiceType {
          display: flex;
          flex-direction: row;
          justify-content: flex-start;
          align-items: center;
          gap: 8px;
          .voiceTypeTitle {
            @include voiceTypeTitle;
          }
          .typeBtn {
            color: rgba(255, 255, 255, 0.8);
            font-weight: 400;
            padding: 4px 24px;
            border: 1px solid var(--border-color);

            &.typeBtnActive {
              border: 1px solid rgba(49, 107, 255, 1);
            }
          }
        }
      }
    }
    .textereaBox {
      width: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: flex-start;
      gap: 12px;

      .voiceDescTitle {
        @include voiceTypeTitle;
      }
      .voiceDescTextareaBox {
        height: 200px;
        width: 100%;
      }
      .voiceDescTextarea {
        width: 100%;
        height: 100%;
        border: 1px solid var(--border-color);
        background-color: #17161a;

        :global(.semi-input-textarea) {
          height: calc(100% - 24px) !important;
        }
      }
    }
    .audioFooter {
      position: relative;
      width: 100%;

      .voiceAudio {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 100;
        width: 100%;
        height: 62px;
        background-color: #17161a;
      }
    }
  }
}
